/**
 * My simple header template from child directory
 * SpecialRunnable.java - ${projectName} - ${organizationName} - ${inceptionYear}
 */
/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 09.03.14
 * Time: 17:10
 * To change this template use File | Settings | File Templates.
 */
public class SpecialRunnable implements Runnable {

    private MethodToStart methodToStart;
    private ConcurrencyClass target;

    public SpecialRunnable(ConcurrencyClass target, MethodToStart methodToStart) {
        this.target = target;
        this.methodToStart = methodToStart;
    }

    @Override
    public void run() {
        methodToStart.run(target);
    }

    enum MethodToStart {
        M1 {
            @Override
            void run(ConcurrencyClass target) {
                target.m1();
            }
        }, M2 {
            @Override
            void run(ConcurrencyClass target) {
                target.m2();
            }
        }, M3 {
            @Override
            void run(ConcurrencyClass target) {
                target.m3();
            }
        }, M4 {
            @Override
            void run(ConcurrencyClass target) {
                target.m4();
            }
        }, M5 {
            @Override
            void run(ConcurrencyClass target) {
                ConcurrencyClass.m5();
            }
        };
        abstract void run(ConcurrencyClass target);
    }

}
